package com.zusmart.base.network;

import java.io.IOException;
import java.nio.channels.Selector;

import com.zusmart.base.network.handler.ChannelContextHandlerChain;
import com.zusmart.base.network.message.Message;
import com.zusmart.base.network.message.MessageFuture;
import com.zusmart.base.toolkit.NetAddress;

public interface ChannelContext {

	public long getRegistTime();

	public long getActiveTime();

	public long getReaderActiveTime();

	public long getWriterActiveTime();

	public long getReaderDataTotal();

	public long getWriterDataTotal();

	public long getReaderDataCount();

	public long getWriterDataCount();

	public boolean isOpen();

	public boolean isServerSide();

	public boolean isClientSide();

	public String getContextCode();

	public NetAddress getServerAddress();

	public NetAddress getClientAddress();

	public ChannelContextFuture close();

	public ChannelContextFuture flush();

	public MessageFuture write(Message message);

	public MessageFuture writeAndFlush(Message message);

	public ChannelContextManager getChannelContextManager();
	
	public ChannelContextHandlerChain getChannelContextHandlerChain();
	
	///////////////////////////////////////////////////////////////////////////
	
	public void doRegister(Selector selector)throws IOException;
	
	public void doListener(int events)throws IOException;
	
	public void deRegister();
	
	public void doException(Throwable cause);
	
	public void doTimeout();
	
	public void doReadable()throws IOException;
	
	public void doWritable()throws IOException;

}